#!/bin/bash

#运行方式：$ sh export-fileName.sh /image/ ./filenames.txt png.meta image
echo "导出当前目录文件名！";
echo "执行的文件名：$0";
echo "第一个参数为文件夹路径：$1";
echo "第二个参数为导出文件名：$2";
echo "第三个参数为搜索文件后缀：$3"; #png.meta
echo "第四个参数为文件夹名称：$4";

path=$1 
tagetFile=$2
files=$(ls -1 -F $path | grep -v [/$])
for filename in $files
do
    result=$(echo $filename | grep "$3")
    if [ "$result" != "" ]
    then
        name=${filename%%.*}
        echo $4$name >> $2
    fi
done
echo 导出完毕

#sh export-fileName.sh ./assets/ChangeClothes/spine_dingzhishaonv/spine_toufaqian filenames.txt png.meta spine_toufaqian/